package com.denso.store.interceptor;

import com.jfinal.aop.Interceptor;
import com.jfinal.aop.Invocation;

/**
 * Created by lijian on 2017/12/7.
 */
public class AdminInterceptor implements Interceptor {

    @Override
    public void intercept(Invocation inv) {
        String admin = inv.getController().getSessionAttr("admin");
        if(admin == null) {
            // unauthorized admin, redirect to login page
            inv.getController().render("/admin/login.html");
        } else {
            // authorized admin, go ahead
            inv.invoke();
        }

    }
}
